/**
 * 
 */
package com.woniuxy.handler;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.woniuxy.pojo.User;
import com.woniuxy.service.UserService;

import lombok.Data;

/**
 * @author Fz
 * @date 2019年8月6日 下午2:49:53
 * @param 
 * @return
 */

@RestController
@RequestMapping("/admin")
@Data
public class AdminHandler {
	
	@Resource
	private UserService userService;
	
	@RequestMapping("/addAdmin")
	public String addAdmin(User user){
		System.out.println("dd");
		boolean flag = userService.addAdmin(user) > 0;
		System.out.println(flag);
		if(flag){
			return "success";
		}else{
			return "fail";
		}
	}
	
	@RequestMapping("/delAdmin")
	public String delAdmin(String uid){
		if(userService.delAdmin(uid) > 0){
			return "删除成功";
		}else{
			return "删除失败";
		}
	}
	
	@RequestMapping("/updateAdmin")
	public String updateA(User user){
		if(userService.updateAdmin(user) > 0){
			return "修改成功";
		}else{
			return "修改失败";
		}
	}	
	@RequestMapping("/showAdmin")
	public List<User> showA(){
		return userService.getAllAdmin();
	}
	@RequestMapping("/findA")
	public List<User> findA(String message){
		List<User> users = userService.find(message);
		return users;
	}
}
